package com.axend.aerosense.home;

import android.content.Context;
import android.util.Log;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import io.reactivex.Observable;
import io.reactivex.functions.BiFunction;
import io.reactivex.functions.Consumer;

/**
 * Instrumented test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
    @Test
    public void useAppContext() {
        // Context of the app under test.
        Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
//        assertEquals("com.axend.aerosense.main.test", appContext.getPackageName());

        List<String> list = new ArrayList<>();
        list.add("wt");
        list.add("aa");
        list.add("bb");
        list.add("cc");
        list.add("dd");

        Observable<String> data = Observable.fromIterable(list);
        Observable<Long> timer = Observable.interval(1, TimeUnit.SECONDS);
        Observable.zip(data, timer, new BiFunction<String, Long, String>() {
            @Override
            public String apply(String s, Long aLong) throws Exception {
                Log.e("TAG", s+ "//" + System.currentTimeMillis());
                return s;
            }
        }).subscribe(new Consumer<String>() {
            @Override
            public void accept(String s) throws Exception {
                Log.e("TAG", s+ "//" + System.currentTimeMillis());
            }
        });
    }
}